             package com.java.diagnostics.visualizer.recommender.sovereign;
             
             import com.java.diagnostics.visualizer.data.AggregateData;
             import com.java.diagnostics.visualizer.data.DataPoint;
             import com.java.diagnostics.visualizer.data.TupleData;
             import com.java.diagnostics.visualizer.recommender.Recommendation;
             import com.java.diagnostics.visualizer.recommender.RecommendationBase;
             import com.java.diagnostics.visualizer.recommender.util.Messages;
             import java.text.MessageFormat;
             
             public class LookForActionCodes
               extends RecommendationBase
               implements Recommendation
             {
               private static final int LARGE_OBJECT_THRESHOLD = 65536;
               private static final String MX = "-mx";
               private static final int MAX_32_BIT_HEAP_SIZE = 1500;
               
               public void recommend(AggregateData data)
               {
                 int[] counts = new int[7];
                 TupleData actions = data.getTupleData("VGCLabels.action");
                 if (actions != null) {
                   DataPoint[] dataPoints = actions.getDataPoints();
                   if (dataPoints.length > 0) {
                     for (int i = 0; i < dataPoints.length; i++) {
                       int action = (int)dataPoints[i].getRawY();
                       counts[action] += 1;
                     }
                   }
                 }
                 
                 if (counts != null)
                 {
                   int count2 = counts[2];
                   if (count2 > 0)
                   {
                     if (count2 > 5) {
                       TupleData requests = data
                         .getTupleData("VGCLabels.request.sizes.which.triggered.failures");
                       
                       DataPoint[] actionPoints = actions.getDataPoints();
                       if (requests != null) {
                         double bigRequests = 0.0D;
                         
                         for (int i = 0; i < actionPoints.length; i++) {
                           if (actionPoints[i].getRawY() == 2.0D)
                           {
                             DataPoint point = requests
                               .getDataPoint(actionPoints[i]
                               .getSequenceUID());
                             if ((point != null) && 
                               (point.getRawY() > 65536.0D)) {
                               bigRequests += 1.0D;
                             }
                           }
                         }
                         
                         if (bigRequests / count2 > 0.4D)
                         {
                           String message2 = 
                             Messages.getString("action.2.comment");
                           addWarning(data, 
                             MessageFormat.format(message2, new Object[] { Integer.valueOf(count2) }));
                           
                           addToCommandLine(data, "-Xloratio", "-Xloratio0.2");
                         }
                       }
                     }
                   }
                   
                   int count3 = counts[3];
                   if (count3 > 0) {
                     String message3 = Messages.getString("action.3.comment");
                     addWarning(data, 
                       MessageFormat.format(message3, new Object[] { Integer.valueOf(count3) }));
                     TupleData LOASize = data
                       .getTupleData("VGCLabels.total.loa.before");
                     TupleData heapSize = data
                       .getTupleData("VGCLabels.flat.heap.size");
                     
                     if ((heapSize != null) && (!heapSize.isEmpty()) && (LOASize != null) && 
                       (!LOASize.isEmpty())) {
                       double currentRatio = LOASize.getRawMeanY() / 
                         heapSize.getRawMeanY();
                       double newRatio = Math.max(currentRatio * 1.5D, 0.2D);
                       
                       addToCommandLine(data, "-Xloratio", "-Xloratio" + 
                         Math.round(newRatio * 10.0D) / 10.0D);
                     }
                   }
                   
                   int count4 = counts[4];
                   if (count4 > 0) {
                     String message4 = Messages.getString("action.4.comment");
                     addWarning(data, 
                       MessageFormat.format(message4, new Object[] { Integer.valueOf(count4) }));
                     
                     suggestOccupancy(data);
                   }
                   int count5 = counts[5];
                   if (count5 > 0) {
                     String message5 = Messages.getString("action.5.comment");
                     addWarning(data, 
                       MessageFormat.format(message5, new Object[] { Integer.valueOf(count5) }));
                     suggestOccupancy(data);
                   }
                   int count6 = counts[6];
                   if (count6 > 0) {
                     String message6 = Messages.getString("action.6.comment");
                     addProblem(data, 
                       MessageFormat.format(message6, new Object[] { Integer.valueOf(count6) }));
                   }
                 }
               }
               
               private void suggestOccupancy(AggregateData data) {
                 TupleData occupancy = data
                   .getTupleData("VGCLabels.live.normal.heap.after.gc");
                 if (occupancy != null) {
                   int meanOccupancyInMB = (int)Math.round(getMeanAsMB(occupancy));
                   int maxOccupancyInMB = (int)Math.round(getMaxAsMB(occupancy));
                   
                   int suggestedHeap = (int)Math.max(meanOccupancyInMB / 0.3D, 
                     maxOccupancyInMB / 0.8D);
                   
                   TupleData heapSize = data.getTupleData("VGCLabels.flat.heap.size");
                   int maxHeapInMB = (int)Math.round(getMaxAsMB(heapSize));
                   
                   if (maxHeapInMB <= 1500) {
                     suggestedHeap = Math.min(1500, suggestedHeap);
                   }
                   
                   addToCommandLine(data, "-mx", "-mx" + suggestedHeap + "m");
                 }
               }
             }


